﻿namespace HRM.REPORT
{
    using APP.HELPER.Data.Helper;
    using APP.HELPER.Utils.CustomizeToolbox;
    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Windows.Forms;

    public class REPORT
    {
        private bool m_Avtive;
        private string m_Class;
        private string m_Comment;
        private string m_DataSet;
        private string m_Description;
        private string m_FileName;
        private string m_Parent_ID;
        private string m_Report_ID;
        private string m_Report_Name;
        private string m_Title;

        public REPORT()
        {
            this.m_Report_ID = "";
            this.m_Report_Name = "";
            this.m_Title = "";
            this.m_Comment = "";
            this.m_FileName = "";
            this.m_Description = "";
            this.m_DataSet = "";
            this.m_Class = "";
            this.m_Parent_ID = "";
            this.m_Avtive = true;
        }

        public REPORT(string Report_ID, string Report_Name, string Title, string Comment, string FileName, string Description, string DataSet, string Class, string Parent_ID, bool Avtive)
        {
            this.m_Report_ID = Report_ID;
            this.m_Report_Name = Report_Name;
            this.m_Title = Title;
            this.m_Comment = Comment;
            this.m_FileName = FileName;
            this.m_Description = Description;
            this.m_DataSet = DataSet;
            this.m_Class = Class;
            this.m_Parent_ID = Parent_ID;
            this.m_Avtive = Avtive;
        }

        public void AddCombo(ComboBox combo)
        {
            GridCalendarControlLib.TableToComboBox(combo, this.GetList(), "REPORTName", "REPORTID");
        }

        public void AddComboAll(ComboBox combo)
        {
            DataTable list = new DataTable();
            list = this.GetList();
            DataRow row = list.NewRow();
            row["REPORTID"] = "All";
            row["REPORTName"] = "Tất cả";
            list.Rows.InsertAt(row, 0);
            GridCalendarControlLib.TableToComboBox(combo, list, "REPORTName", "REPORTID");
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@Report_ID" };
            object[] myValues = new object[] { this.m_Report_ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("REPORT_Delete", myParams, myValues);
        }

        public string Delete(string Report_ID)
        {
            string[] myParams = new string[] { "@Report_ID" };
            object[] myValues = new object[] { Report_ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("REPORT_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, string Report_ID)
        {
            string[] myParams = new string[] { "@Report_ID" };
            object[] myValues = new object[] { Report_ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "REPORT_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, string Report_ID)
        {
            string[] myParams = new string[] { "@Report_ID" };
            object[] myValues = new object[] { Report_ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "REPORT_Delete", myParams, myValues);
        }

        public bool Exist(string Report_ID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@Report_ID" };
            object[] myValues = new object[] { Report_ID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("REPORT_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(SqlConnection myConnection, string Report_ID)
        {
            string str = "";
            string[] myParams = new string[] { "@Report_ID" };
            object[] myValues = new object[] { Report_ID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "REPORT_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_Report_ID = Convert.ToString(reader["Report_ID"]);
                    this.m_Report_Name = Convert.ToString(reader["Report_Name"]);
                    this.m_Title = Convert.ToString(reader["Title"]);
                    this.m_Comment = Convert.ToString(reader["Comment"]);
                    this.m_FileName = Convert.ToString(reader["FileName"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_DataSet = Convert.ToString(reader["DataSet"]);
                    this.m_Class = Convert.ToString(reader["Class"]);
                    this.m_Parent_ID = Convert.ToString(reader["Parent_ID"]);
                    this.m_Avtive = Convert.ToBoolean(reader["Avtive"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, string Report_ID)
        {
            string str = "";
            string[] myParams = new string[] { "@Report_ID" };
            object[] myValues = new object[] { Report_ID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "REPORT_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_Report_ID = Convert.ToString(reader["Report_ID"]);
                    this.m_Report_Name = Convert.ToString(reader["Report_Name"]);
                    this.m_Title = Convert.ToString(reader["Title"]);
                    this.m_Comment = Convert.ToString(reader["Comment"]);
                    this.m_FileName = Convert.ToString(reader["FileName"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_DataSet = Convert.ToString(reader["DataSet"]);
                    this.m_Class = Convert.ToString(reader["Class"]);
                    this.m_Parent_ID = Convert.ToString(reader["Parent_ID"]);
                    this.m_Avtive = Convert.ToBoolean(reader["Avtive"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(string Report_ID, string Language_Id)
        {
            string str = "";
            string[] myParams = new string[] { "@Report_ID", "@Language_Id" };
            object[] myValues = new object[] { Report_ID, Language_Id };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("REPORT_Get_By_Language", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_Report_ID = Convert.ToString(reader["Report_ID"]);
                    this.m_Title = Convert.ToString(reader["Title"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("REPORT_GetList");
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@Report_ID", "@Report_Name", "@Title", "@Comment", "@FileName", "@Description", "@DataSet", "@Class", "@Parent_ID", "@Avtive" };
            object[] myValues = new object[] { this.m_Report_ID, this.m_Report_Name, this.m_Title, this.m_Comment, this.m_FileName, this.m_Description, this.m_DataSet, this.m_Class, this.m_Parent_ID, this.m_Avtive };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("REPORT_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@Report_ID", "@Report_Name", "@Title", "@Comment", "@FileName", "@Description", "@DataSet", "@Class", "@Parent_ID", "@Avtive" };
            object[] myValues = new object[] { this.m_Report_ID, this.m_Report_Name, this.m_Title, this.m_Comment, this.m_FileName, this.m_Description, this.m_DataSet, this.m_Class, this.m_Parent_ID, this.m_Avtive };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "REPORT_Insert", myParams, myValues);
        }

        public string Insert(string Report_ID, string Report_Name, string Title, string Comment, string FileName, string Description, string DataSet, string Class, string Parent_ID, bool Avtive)
        {
            string[] myParams = new string[] { "@Report_ID", "@Report_Name", "@Title", "@Comment", "@FileName", "@Description", "@DataSet", "@Class", "@Parent_ID", "@Avtive" };
            object[] myValues = new object[] { Report_ID, Report_Name, Title, Comment, FileName, Description, DataSet, Class, Parent_ID, Avtive };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("REPORT_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, string Report_ID, string Report_Name, string Title, string Comment, string FileName, string Description, string DataSet, string Class, string Parent_ID, bool Avtive)
        {
            string[] myParams = new string[] { "@Report_ID", "@Report_Name", "@Title", "@Comment", "@FileName", "@Description", "@DataSet", "@Class", "@Parent_ID", "@Avtive" };
            object[] myValues = new object[] { Report_ID, Report_Name, Title, Comment, FileName, Description, DataSet, Class, Parent_ID, Avtive };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "REPORT_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, string Report_ID, string Report_Name, string Title, string Comment, string FileName, string Description, string DataSet, string Class, string Parent_ID, bool Avtive)
        {
            string[] myParams = new string[] { "@Report_ID", "@Report_Name", "@Title", "@Comment", "@FileName", "@Description", "@DataSet", "@Class", "@Parent_ID", "@Avtive" };
            object[] myValues = new object[] { Report_ID, Report_Name, Title, Comment, FileName, Description, DataSet, Class, Parent_ID, Avtive };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "REPORT_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("REPORT", "REPORT_ID", "");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@Report_ID", "@Report_Name", "@Title", "@Comment", "@FileName", "@Description", "@DataSet", "@Class", "@Parent_ID", "@Avtive" };
            object[] myValues = new object[] { this.m_Report_ID, this.m_Report_Name, this.m_Title, this.m_Comment, this.m_FileName, this.m_Description, this.m_DataSet, this.m_Class, this.m_Parent_ID, this.m_Avtive };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("REPORT_Update", myParams, myValues);
        }

        public string Update(string Report_ID, string Report_Name, string Title, string Comment, string FileName, string Description, string DataSet, string Class, string Parent_ID, bool Avtive)
        {
            string[] myParams = new string[] { "@Report_ID", "@Report_Name", "@Title", "@Comment", "@FileName", "@Description", "@DataSet", "@Class", "@Parent_ID", "@Avtive" };
            object[] myValues = new object[] { Report_ID, Report_Name, Title, Comment, FileName, Description, DataSet, Class, Parent_ID, Avtive };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("REPORT_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, string Report_ID, string Report_Name, string Title, string Comment, string FileName, string Description, string DataSet, string Class, string Parent_ID, bool Avtive)
        {
            string[] myParams = new string[] { "@Report_ID", "@Report_Name", "@Title", "@Comment", "@FileName", "@Description", "@DataSet", "@Class", "@Parent_ID", "@Avtive" };
            object[] myValues = new object[] { Report_ID, Report_Name, Title, Comment, FileName, Description, DataSet, Class, Parent_ID, Avtive };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "REPORT_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, string Report_ID, string Report_Name, string Title, string Comment, string FileName, string Description, string DataSet, string Class, string Parent_ID, bool Avtive)
        {
            string[] myParams = new string[] { "@Report_ID", "@Report_Name", "@Title", "@Comment", "@FileName", "@Description", "@DataSet", "@Class", "@Parent_ID", "@Avtive" };
            object[] myValues = new object[] { Report_ID, Report_Name, Title, Comment, FileName, Description, DataSet, Class, Parent_ID, Avtive };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "REPORT_Update", myParams, myValues);
        }

        public bool Avtive
        {
            get
            {
                return this.m_Avtive;
            }
            set
            {
                this.m_Avtive = value;
            }
        }

        public string Class
        {
            get
            {
                return this.m_Class;
            }
            set
            {
                this.m_Class = value;
            }
        }

        public string Comment
        {
            get
            {
                return this.m_Comment;
            }
            set
            {
                this.m_Comment = value;
            }
        }

        public string DataSet
        {
            get
            {
                return this.m_DataSet;
            }
            set
            {
                this.m_DataSet = value;
            }
        }

        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        public string FileName
        {
            get
            {
                return this.m_FileName;
            }
            set
            {
                this.m_FileName = value;
            }
        }

        public string Parent_ID
        {
            get
            {
                return this.m_Parent_ID;
            }
            set
            {
                this.m_Parent_ID = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class REPORT";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        public string Report_ID
        {
            get
            {
                return this.m_Report_ID;
            }
            set
            {
                this.m_Report_ID = value;
            }
        }

        public string Report_Name
        {
            get
            {
                return this.m_Report_Name;
            }
            set
            {
                this.m_Report_Name = value;
            }
        }

        public string Title
        {
            get
            {
                return this.m_Title;
            }
            set
            {
                this.m_Title = value;
            }
        }
    }
}

